home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9310.ZIP / 1993-OCT.ZIP / 68HC11.ASC next >
Text File  |  1993-09-17  |  1KB  |  41 lines

  1. _AVOIDING MICROCONTROLLER PROCESSING PILEUPS_
  2. by Eric McRae
  3.  
  4. [LISTING ONE]
  5.  
  6. /* 6 KHZ interrupt handler. Called from timer ISR. Makes use of INTSOFF
  7. ** and INTSON macros which disable and enable interrupts. */
  8. void
  9. sixkhz()
  10. (
  11.     int hit, i;
  12.     do6kdft();          /* Handle voice DFT processing */
  13.     hit = -1;           /* Assume no counter hits zero */
  14.  
  15.     for( i = 0; i < MAXCTRS; i++ ) /* Decrement each Counter */
  16.     (
  17.     if( ! counter[i]-- )
  18.     (           /* if this counter hit 0 */
  19.         if( hit != -1 ) /* If another counter already expired */
  20.         {       /* Oh No! Processing Pile */
  21.         }
  22.         else hit = i;   /* Else save index of ctr hitting 0 */
  23.     )
  24.     )               /* end of for each counter */
  25.     if( hit != -1 )
  26.     (               /* If a counter did hit zero */
  27.     INTSOFF;        /* Disable Interrupts */
  28.     if(busyN++)     /* If already running a handler */
  29.     {       /* Overrun Error if get here (Busy was already set)*/
  30.     )
  31.     INTSON;         /* Enable interrupts */
  32.     (do_handler[i])();  /* invoke processing handler */
  33.     INTSOFF;        /* Disable interrupts */
  34.     counter[i] += resetval[i] ) /* Reload ctr considering */
  35.                     /* time already used */
  36.     busyN = 0;      /* clear busy flag */
  37.     INTSON;         /* enable interrupts */
  38.     )           /* End of it counter expired */
  39. )
  40.  
  41.